#include <stdlib.h>

#include "lib.h"

#include "slotguts.h"
#include "diamguts.h"


enum WheelContents 
{ 
    BLANK, 
    SEVEN, 
    DIAMOND, 
    BAR1, 
    BAR2, 
    JACKPOT
};



enum SpinResult
{
	EVT_LOSER = 0,
	EVT_1DIAMOND,
	EVT_2DIAMONDS,
	EVT_ANY3BARS,
	EVT_3BARS,
	EVT_3BARBARS,
	EVT_3SEVENS,
	EVT_3DIAMONDS,
	EVT_3JACKPOTS,
	NUMEVENTS,
};

bool8 
DiamSlotGuts::isValidGuts()
{
    return getGutsId() == 100 ||
           getGutsId() == 101 ||
           getGutsId() == 102 ||
           getGutsId() == 103 ||
           getGutsId() == 104 ||
           getGutsId() == 105 ||
           getGutsId() == 106 ||
           getGutsId() == 107;
}


uint8
DiamSlotGuts::classifyStops(uint8* stops,uint8 bet, uint8 line)
{
	uint8 result = EVT_LOSER;

	// 3-in-a-row
	//
	if ( getIcon(0, stops[0])->iconid == getIcon(1, stops[1])->iconid &&
		getIcon(1, stops[1])->iconid == getIcon(2, stops[2])->iconid)
	{
		switch ( getIcon(0, stops[0])->iconid )
		{
			case DIAMOND:	result = EVT_3DIAMONDS;	break;
			case BAR1:		result = EVT_3BARS;		break;
			case BAR2:		result = EVT_3BARBARS;	break;
			case SEVEN:		result = EVT_3SEVENS;	break;
			case JACKPOT:	result = EVT_3JACKPOTS;	break;
			default:
				break;
		}
	}
	else
	{
		int i, bars = 0, diamonds = 0;

		for (i = 0; i < getReelCount(); i++)
			switch ( getIcon(i, stops[i])->iconid )
			{
				case DIAMOND:
					++diamonds;
					break;
				case BAR1:
				case BAR2:
					++bars;
					break;
				default:
					break;
			}

		if (bars == 3)
			result = EVT_ANY3BARS;
		else if (diamonds > 0)
			result = (diamonds == 2 ? EVT_2DIAMONDS : EVT_1DIAMOND);
	}

	return result;
}
